;var module = angular.module('CtrlsContent');
module.controller('ListSelectCtrl',['$scope','$state','api_other',function($scope,$state,api_other){
	$scope.listModel = {
		model:[],
		get:function(id){
			var self = this;
			var promise = api_other.testList(id);
			promise.success(function(data){
				if(data.returnCode == 0){
					self.model = data.returnData
				}
			});
			return promise;
		}
	};
	$scope.event = {
		getList:function(item){
			var id;
			if(item){
				id = item.id;
			}
			if(id == undefined){
				id = localStorage.catId;
				if(!localStorage.catId){
					alert('请返回初始页选择考试分类')
					$state.go('testList');
				}
			}
			var promise = $scope.listModel.get(id);
			promise.success(function(data){
				if(data.returnCode == 999){
					$state.go('zhangjieContent',{param:1});
					if(item)
						localStorage.zhangjieCatId = item.id;
					else
						localStorage.zhangjieCatId = localStorage.catId;
				}else if(data.returnCode == 0){
					if(item){
						$scope.eleStatus.title = item.catname;
						localStorage.zhangjieCatId = item.id;
					}else{
						$scope.eleStatus.title = '选择科目';
					}
				}
			});
		}
	};
	$scope.eleStatus = {
		title:'选择科目'
	};

	$scope.event.getList();
}]);